package com.yonyou.pmclouds.workconnect.service.rmiimpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.ref.itf.RefCodeConst;
import com.yonyou.pmclouds.basecom.ref.itf.ReferenceCheckOfBusiness;
import com.yonyou.pmclouds.workConnect.entity.WorkConnectVO;
import com.yonyou.pmclouds.workConnect.service.rmiitf.WorkConnectQuery;

@Component
public class ReferenceCheckOfWorkConnect implements ReferenceCheckOfBusiness{
    @Autowired
    private WorkConnectQuery query;
    @Override
    public String[] getReferenceCode() {
        return new String[]{RefCodeConst.PROJECT,RefCodeConst.PROCEDURE,RefCodeConst.CONTACTTYPE};
    }

    @Override
    public boolean checkReferenced(String bdCode, String[] keys) throws BusinessException {
        String code = null;
        if(RefCodeConst.PROJECT.equals(bdCode)) {
            code = WorkConnectVO.PK_PROJECT;
        } else if(RefCodeConst.PROCEDURE.equals(bdCode)) {
            code = WorkConnectVO.PK_PROCESS;
        } else if(RefCodeConst.CONTACTTYPE.equals(bdCode)) {
            code = WorkConnectVO.PK_CONTATTYPE;
        }else {
            throw new BusinessException("工作联系暂未引用该档案!");
       }
       return query.queryRefByIds(code, keys);
    }

}
